﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HNCDataSetTableAdapters;

public partial class UserControl_news_reference : System.Web.UI.UserControl
{
    ProductsTableAdapter pro = new ProductsTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int ProductIDReference = int.Parse(HttpContext.Current.Request.RequestContext.RouteData.Values["ProductID"].ToString());
            DataTable dt = pro.GetProductByProductID(ProductIDReference);
            int CateID = int.Parse(dt.Rows[0]["CateID"].ToString());
            ltrProductReference.Text = loadRefernece(CateID, ProductIDReference);
        }
    }

    public string loadRefernece(int CateID, int ProductIDReference)
    {
        DataTable dt = pro.GetProductReference(CateID, ProductIDReference);
        string str = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string Title = dt.Rows[i]["Title"].ToString();
            string ProductID = dt.Rows[i]["ProductID"].ToString();
            DateTime EditDate = (DateTime)(dt.Rows[i]["EditDate"]);
            string EditDate1 = EditDate.ToString("dd/MM/yyyy");
            str += "<li><a href=\"chi-tiet-tin-tuc-du-an-" + ProductID + ".html\">" + Title + " (" + EditDate1 + ")" + "</a></li>";
        }
        return str;
    }
}